package com.zlp.spring.aop;

import com.zlp.spring.aop.config.AopConfig;
import com.zlp.spring.aop.service.*;
import com.zlp.spring.aop.service.Math;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
 * Aop测试
 * @date: 2022/2/28 13:36
 */
public class AopTest {

    public static void main(String[] args) {

        ApplicationContext ac = new AnnotationConfigApplicationContext(AopConfig.class);

//        MathService mathService = ac.getBean("mathService", MathService.class);
        Math mathService = (Math) ac.getBean("mathService");
        mathService.division(1, 0);

//        MyClass myClass = ac.getBean(MyClass.class);
//        Pen pen = ac.getBean(Pen.class);
//        myClass.write(pen);


        // debug调试==>控制台返回的值：调用toString方法返回值
//        A a = new A();
//        TestSevice testSevice = ac.getBean("test",TestSevice.class);
//        // JDK动态代理==》TestServiceImpl实现了TestSevice接口
//        testSevice.query("zlp");

    }
}
